import { replaceImageUrl } from "@/utils";
// css
import styles from '@/styles/CommonDetail.module.scss';

export default function DetailText({ data }) {
    return (
        <div className={styles['detail']}>
            <article className={styles['text']}>
                {
                    data.map((item, index) => {
                        const { type: itemType, value } = item;
                        if (itemType === 'content') {
                            return <p className={styles['text-item']} key={index} dangerouslySetInnerHTML={{__html: value}}></p>
                        }
                        if (itemType === 'img') {
                            return <p className={styles['text-item']} key={index}><img src={replaceImageUrl(value)} alt="" /></p>
                        }
                        return ""
                    })
                }
            </article>
        </div>
    )
}